package com.itchen.hospital.mapper;

import com.itchen.hospital.pojo.Doctor;
import com.itchen.hospital.pojo.Params;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DoctorMapper {
    /**
     * 查询所有医生
     *
     * @return
     */
    List<Doctor> getAll();

    /**
     * 条件查询医生
     *
     * @param params
     * @return
     */
    List<Doctor> findBySearch(@Param("params") Params params);

    /**
     * 添加医生
     *
     * @param doctor
     */
    void add(Doctor doctor);

    /**
     * 修改医生
     *
     * @param doctor
     */
    void update(Doctor doctor);

    /**
     * 根据account查询医生
     *
     * @param account
     * @return
     */
    @Select("select doctor.* , administrative.DepartmentName from doctor left join administrative on doctor.administrativeId = administrative.id where account=#{account}")
    Doctor findByAccount(String account);

    /**
     * 根据account删除医生
     *
     * @param account
     */
    @Delete("delete from doctor where account=#{account}")
    void delete(String account);

    /**
     * 根据id查询医生
     *
     * @param id
     * @return
     */
    @Select("select * from doctor where id = #{id}")
    Doctor findById(Integer id);
}
